package com.nxy.cpfsfe.mybatis.service;

import java.util.Date;

import org.apache.ibatis.session.SqlSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.DefaultTransactionDefinition;

import com.adtec.starring.exception.BaseException;
import com.adtec.starring.util.SpringUtil;
import com.nxy.cpfsfe.enumtype.RespCd;
import com.nxy.cpfsfe.mybatis.mapper.TeBatchReqMapper;
import com.nxy.cpfsfe.mybatis.pojo.TeBatchReq;

public class TeBatchReqService {
	private final static Logger LOGGER = LoggerFactory.getLogger(TeBatchReqService.class);

	/**
	 * 更新批量请求表
	 * @param teBatchReq
	 */
	public static void updateTeBatchReq(TeBatchReq teBatchReq){
		try {
			//插入数据	
			SqlSession mybatisSqlSession =(SqlSession) SpringUtil.getBean("mybatisSqlSession");
			TeBatchReqMapper tMapper = mybatisSqlSession.getMapper(TeBatchReqMapper.class);
			teBatchReq.setProcTm(new Date());
			int num =tMapper.updateTeBatchReqPo(teBatchReq);
		} catch (Exception e) {
			LOGGER.error("更新数据失败：批量请求登记表teBatchReq",e);
			throw new BaseException(RespCd.NCPO6050,e,"批量请求登记表teBatchReq");
		}
		
	}
	/**
	 * 更新批量请求表状态
	 * @param teBatchReq
	 */
	public static void updateTeBatchReqStatus(TeBatchReq teBatchReq){
		try {
			//插入数据
			SqlSession mybatisSqlSession =(SqlSession) SpringUtil.getBean("mybatisSqlSession");
			TeBatchReqMapper tMapper = mybatisSqlSession.getMapper(TeBatchReqMapper.class);
			teBatchReq.setProcTm(new Date());
			tMapper.updateTeBatchReqStatus(teBatchReq);
		} catch (Exception e) {
			LOGGER.error("更新数据失败：批量请求登记表teBatchReq",e);
			throw new BaseException(RespCd.NCPO6050,e,"批量请求登记表teBatchReq");
		}

	}
}
